#!/usr/bin/env python
import sys
import class_set
import helper
import copy
from sets import Set

class FeedRecommendationReducer(helper.ReducerHelper):

    def processor(self, key, lst):
        feed = Set()
        user = Set()
        for e in lst:
            if class_set.RecomTagFeed.isMumber(e):
                recom_tag = class_set.RecomTagFeed('')
                recom_tag.init(e)
                recom_tag.setIsResult(True)
                feed.add(recom_tag)
            else:
                user.add(e)
        for u in user:
            for f in feed:
                item_id = f.getRelatedId()
                left = self.join(u, item_id)
                self.allocator(left, f)

def main():
    fr = FeedRecommendationReducer()
    fr.reducer()

if __name__ == '__main__':
    main()









